import { IManagement } from "@/api";
import { Badge, Button } from "@/components";
import { FormItem } from "@/components/SearchForm/formTypes";
import { OPERATE_COLUMN } from "@/config";
import { REPORT_STATUS, TASK_KEY } from "@/constants";
import { OptionsUtil } from "@/utils";
import { ColumnType, ColumnsType } from "antd/es/table";

export const getFields = (): FormItem[] => [
  {
    type: "Select",
    formItemProps: {
      name: "type",
      label: "资产类型",
      initialValue: "",
    },
    props: {
      options: OptionsUtil.getSimpleData(TASK_KEY),
    },
  },
];

export const getColumns = (
  options
): ColumnsType<IManagement.ResManagementItem> => {
  return options.map((item) => {
    if (item.dataIndex === "reportState") {
      return {
        ...item,
        render(text) {
          if (text === 0) return <Badge status="error" text="失败" />
          if (text === 1) return <Badge status="success" text="成功" />
        },
      };
    }
    return item;
  });
}
